<?php 

/**
 * ControlEconomicoDocumentos
 * 
 * @package Sgit 
 * @author Juan Manuel Martinez Carrillo
 * @copyright Juan Manuel Martinez Carrillo
 * @version 2012
 * @access public
 * @revision 17/02/2012 12:19:36
 */

 
 
class DocumentosControlEconomicoController extends Sgit_Controller_Action
{
	
    protected $_main_model='DocumentosControlEconomico';
    protected $_main_form='DocumentosControlEconomico';


    function _begin(){
            
        $this->_file_upload[1] = Sgit_Util_FileUpload::run('archivos','control-economico');
    }
    
    
    
	public function indexAction()
    {
        $rows = $this->_model->default->GetAll();
        $this->view->rows=$rows;
    }
    


    public function insertarAction()
    {
        $this->_reload();
    	$this->_insertar();
    }
    

    
    public function editarAction()
    {
        $this->_reload();
        $this->_editar();
    }
    
    public function borrarAction()
    {
        $this->_reload();
        $this->_borrar();
    }


    protected function _prepareValuesToDb()
    {
        
        $row=$this->_form->getValues();
        
        Sgit_Util_removeFiles::run($this->_file_upload[1]['tabla'],$this->_file_upload[1]['key'],$this->_id,$row[$this->_file_upload[1]['activo']]);
        unset($row[$this->_file_upload[1]['name']]);
        unset($row[$this->_file_upload[1]['activo']]);
        
        
        return $row;
    }
    

}




